﻿using SqlSugar;

namespace Koala.Pro.Core.Models;

[SugarTable("T_ACL_OperationLog")]
public class OperationLogInfo : Entity<string>
{
    public virtual string User_ID { get; set; }

    public virtual string LoginName { get; set; }

    public virtual string FullName { get; set; }

    public virtual string Company_ID { get; set; }

    public virtual string CompanyName { get; set; }

    public virtual string TableName { get; set; }

    public virtual string OperationType { get; set; }

    public virtual string Note { get; set; }

    public virtual string IPAddress { get; set; }

    public virtual string MacAddress { get; set; }

    public virtual DateTime? CreateTime { get; set; }

    public OperationLogInfo()
    {
        Id = Guid.NewGuid().ToString();
        CreateTime = DateTime.Now;
    }

    public OperationLogInfo(IApiUserSession user, string tableName, string operationType, string note)
        : this()
    {
        CompanyName = user.CompanyName;
        Company_ID = user.Company_ID;
        User_ID = user.Id?.ToString();
        FullName = user.FullName;
        IPAddress = user.IP;
        MacAddress = user.MacAddr;
        LoginName = user.Name;
        Note = note;
        TableName = tableName;
        OperationType = operationType;
    }
}
